package com.jinsi.controller.tang;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jinsi.constant.YltConstant;
import com.jinsi.pojo.Commodity;
import com.jinsi.service.tang.CommodityAuditLogService;
import com.jinsi.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品历史价格列表
 * @author 唐文博
 * @Date 2022-08-22
 */
@RestController
@RequestMapping("/commodityAuditLog")
public class CommodityAuditLogController {
    @Autowired
    private CommodityAuditLogService commodityAuditLogService;

    /**
     * 筛选搜索查询,根据商品名称、商品分类、操作时间查询
     * @param page
     * @param limit
     * @param commodityName
     * @param commodityCode
     * @param createDate
     * @return
     */
    @RequestMapping("/getCommodityAuditLog")
    public R getCommodityAuditLog(Integer page, Integer limit, String commodityName,
                                                    Integer commodityCode, String createDate){
        PageHelper.startPage(page,limit);
        List<Commodity> list = commodityAuditLogService.getCommodityAuditLog(commodityName, commodityCode,
                createDate);
        PageInfo<Commodity> pageInfo = new PageInfo<>(list);
        return R.custom(YltConstant.LAYUI_CODE,
                YltConstant.LAYUI_MSG,
                pageInfo.getList(),
                pageInfo.getTotal());
    }
}
